<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<title>新增短信方配置</title>
<@fm.header />
</head>
<body>
<div class="easyui-layout" style="text-align: center; height: 500px;" fit="true">
	<div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
	<form id="ff" method="post">
	    <table>
	        <tr>
	            <td><label for="name">名称:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="name" data-options="required:true,validType:'length[1,255]'"></input></td>
	            
	       </tr>
	        <tr>
	            <td><label for="code">编码:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="code" data-options="required:true,validType:'length[1,255]'"></input></td>
	        </tr>
	        
	        <tr>
	            <td><label for="taskNum">数量:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="taskNum" ></input></td>
	        </tr>
	        
	        <tr>
	            <td><label for="sendSms">发送短信内容:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="sendSms" ></input></td>
	        </tr>
	        
	        <tr>
	        <td><label for="carrier">运营商</label></td>
	            <td>
	            	<input type="checkbox" name="carrierCheck" value="2" >移动</input>
	            	<input type="checkbox" name="carrierCheck" value="1" >联通</input>
	            	<input type="checkbox" name="carrierCheck" value="0" >电信</input>
	            	<input id="carrier" type="hidden" name="carrier">
	            </td>
	         </tr>
	         
	       <tr>    
	            <td><label for="channelName">限制渠道:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="channelName"></input>  </td>
	        </tr>
	        
	        <tr>    
	            <td><label for="filterChannel">过滤渠道:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="filterChannel"></input>  </td>
	        </tr>
	         
	         
	         <tr>
	            <td><label for="sendPhoneNum">发送短信号码:</label></td>
	            <td><input class="easyui-validatebox" type="text" name="sendPhoneNum" ></input></td>
	        </tr>
	        
	        <tr>
	            <td><label for="taskType">任务类型:</label></td>
	            <td> <select class="easyui-combobox" name="taskType" panelHeight="auto" style="width:155px" data-options="required:true">
		                <option value="1" selected>发送短信接收验证码</option>
	                	<option value="0">接收验证码</option>
                   		 <option value="2">发送短信</option>
		            </select>
	    	 </td>
	        </tr>
	        
	         <tr>
	            <td><label for="callbackUrl">回调地址:</label></td>
	            <td><input class="easyui-validatebox" type="text"  name="callbackUrl" style="width:400px" data-options="validType:'url'"></input></td>
	        </tr>
	         <tr>
	            <td><label for="smsId">拦截策略:</label></td>
	            <td colspan="3"><input id="interceptId" class="easyui-combogrid" style="width: 400px;height: 22px;" name="smsId" data-options="
						panelHeight: '150',
						multiple:true,
						multiline:true,
						url:'/interceptInfo/content?defaultValues=0',
						method:'get',
						idField: 'id',
            			textField: 'msgContent',
						columns: [[
							{field:'id',title:'编号',width:30},
			                {field:'msgContent',title:'拦截策略',width:150},
			                {field:'regexContent',title:'正则表达式验证码',width:120}
			            ]],
            			fitColumns: true 
						"/>
	            </td>		
	        </tr>	
	    </table>
	</form>
	</div>
	<div region="south" border="false" style="text-align: center; padding: 5px 5px 5px 0;">
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="add()">提交</a>
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm();">重置</a>
	</div>
</div>
<script>
$(function(){
	$("input").bind("keyup afterpaste", function(){
		$(this).val($(this).val().replace(/\s/g,''));
	});
});

function add() {
	$('#ff').form(
	    'submit',
	    {
			url : '/smsconfig/add',
			onSubmit : function() {
			 	var f_str = '';
				var groupCheckbox=$("input[name='carrierCheck']");
			    for(i=0;i<groupCheckbox.length;i++){
			        if(groupCheckbox[i].checked){
			            var val =groupCheckbox[i].value;
						f_str +=val+",";
			        }
			    }
			    $('#carrier').val(f_str)
				return $(this).form('enableValidation').form('validate');
			},
			success : function(data) {
				showProcess(false);
				var data = eval("(" + data + ")");
				if (data.return_code == '1') {
					top.showMsg(market.content.title, data.return_msg, alert);
					if (parent !== undefined) {
						if ($.isFunction(parent.reloadParent)) {
							parent.reloadParent.call();
							parent.closeMyWindow();
						} else {
							parent.$("#tt").datagrid('reload');
							parent.closeMyWindow();
						}
					}
				}else if(data.return_code == '10'){
					$.messager.alert(market.content.title, data.return_msg);
					if (parent !== undefined) {
						if ($.isFunction(parent.reloadParent)) {
							parent.reloadParent.call();
							parent.closeMyWindow();
						} else {
							parent.$("#tt").datagrid('reload');
							parent.closeMyWindow();
						}
					}
				} else {
					$.messager.alert(market.content.title, data.return_msg);
				}
			},
			onLoadError : function() {
				showProcess(false);
				$.messager.alert(market.content.title, market.content.networkError);
			}
		}); 
}
</script>


</body>
</html>